/**
 *
 * @param {Function} fn 绑定this的函数
 * @param {Object} obj this
 * @param  {...any} args fn传入的参数
 */
export function call(fn, obj, ...args) {
  if (typeof fn !== 'function') {
    throw new TypeError('fn is not a function')
  }
  obj = obj || window

  obj.tempFn = fn
  const result = obj.tempFn(...args)
  delete obj.tempFn

  return result
}
